//
//  common.swift
//  DYSwiftFramework
//
//  Created by huangdeyu on 2021/10/20.
//  Copyright © 2021 none. All rights reserved.
//

import Foundation
import UIKit


private var _isiPhoneX:Bool?
/// 判断是否是刘海屏
var isiPhoneXScreen:Bool {
    guard #available(iOS 11.0, *) else {
        return false
    }
    if let isX = _isiPhoneX {
        return isX
    }
    _isiPhoneX = UIApplication.shared.windows[0].safeAreaInsets.bottom > 0
    return _isiPhoneX!
}


private var status_bar_height:Double?
/// 状态栏高度
var STATUS_BAR_HEIGHT:Double {
    guard #available(iOS 11.0, *) else {
        return 0
    }
    if let h = status_bar_height {
        return h
    }
    if !isiPhoneXScreen {
        return 20
    }
    status_bar_height = UIApplication.shared.windows[0].safeAreaInsets.top.double
    return status_bar_height!
}

private var bottom_inset:Double?
/// 底部安全距离
var BOTTOM_INSET:Double {
    guard #available(iOS 11.0, *) else {
        return 0
    }
    if let h = bottom_inset {
        return h
    }
    if !isiPhoneXScreen {
        return 0
    }
    bottom_inset = UIApplication.shared.windows[0].safeAreaInsets.bottom.double
    return bottom_inset!
}

var TABBAR_HEIGHT:Double {
    return BOTTOM_INSET + 49
}

var NAV_HEIGHT:Double {
    return STATUS_BAR_HEIGHT + 44
}


var SCREEN_W:CGFloat {
    return UIScreen.main.bounds.size.width
}

var SCREEN_H:CGFloat {
    return UIScreen.main.bounds.size.height
}


